package generic;

import utils.Log;

import java.util.ArrayList;
import java.util.Random;

public class RnadomList<T> {
    private ArrayList<T> storage = new ArrayList<>();
    private Random random = new Random(47);

    public void add(T item) {
        storage.add(item);
    }

    public T select() {
        // 随机选取一个值
        return storage.get(random.nextInt(storage.size()));
    }

    public static void main(String[] args) {
        RnadomList<String> rs = new RnadomList<>();
        for (String s : "Phasers on stun!".split(" ")) {
            rs.add(s);
        }

        int i = 0;
        while (i < 3) {
            Log.vn(rs.select());
            i++;
        }

    }
}
